from flask import Flask, request, jsonify
import ollama

app = Flask(__name__)

@app.route('/api/qa', methods=['POST'])
def handle_question():
    data = request.json
    response = ollama.generate(
        model="llama3",
        prompt=data.get('question', ''),
        stream=False
    )
    return jsonify({
        "answer": response['response']
    })

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5001)